#include <extend.h>

//----------------------------------------------------------------------------//

LONG abs( long l )
{
   return IF( l < 0, -l, l );
}

//----------------------------------------------------------------------------//

short bin2i( LPSTR szBin )
{
   short s = 0;
   WORD wLen = _strlen( szBin );

   if( wLen > 0 )
      s += szBin[ 0 ];

   if( wLen > 1 )
      s += szBin[ 1 ] * 256;

   return s;
}

//----------------------------------------------------------------------------//

WORD bin2w( LPSTR szBin )
{
   WORD w = 0;
   WORD wLen = _strlen( szBin );

   if( wLen > 0 )
      w += szBin[ 0 ];

   if( wLen > 1 )
      w += szBin[ 1 ] * 256;

   return w;
}

//----------------------------------------------------------------------------//

LONG max( LONG l1, LONG l2 )
{
   return IF( l1 > l2, l1, l2 );
}

//----------------------------------------------------------------------------//

LONG min( LONG l1, LONG l2 )
{
   return IF( l1 < l2, l1, l2 );
}

//----------------------------------------------------------------------------//

CLIPPER ABS()
{
   _retnl( abs( _parnl( 1 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER BIN2I()
{
   _retni( bin2i( _parc( 1 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER BIN2W()
{
   _retnl( bin2w( _parc( 1 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER MAX()
{
   _retnl( max( _parnl( 1 ), _parnl( 2 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER MIN()
{
   _retnl( min( _parnl( 1 ), _parnl( 2 ) ) );
}

//----------------------------------------------------------------------------//
